package cn.school.mybatis.service;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import cn.school.mybatis.dao.GradeDao;
import cn.school.mybatis.dao.SubjectDao;
import cn.school.mybatis.pojo.Grade;
import cn.school.mybatis.pojo.Subject;
import cn.school.mybatis.util.MyBatisUtil;

public class SubjectService {
	public List<Subject> select(int pageNo, int pageSize) {
		SqlSession s = MyBatisUtil.get();
		try {
			SubjectDao dao = s.getMapper(SubjectDao.class);
			List<Subject> list = dao.search(pageNo, pageSize);
			return list;
		} finally {
			MyBatisUtil.close(s);
		}
	}

	public int getTotal() {
		SqlSession s = MyBatisUtil.get();
		try {
			SubjectDao dao = s.getMapper(SubjectDao.class);
			return dao.getTotal();
		} finally {
			MyBatisUtil.close(s);
		}
	}
}
